home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_mysql.idb / usr / freeware / include / mysql / my_sys.h.z / my_sys.h
C/C++ Source or Header  |  2002-10-07  |  26KB  |  625 lines

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This library is free software; you can redistribute it and/or
  4.    modify it under the terms of the GNU Library General Public
  5.    License as published by the Free Software Foundation; either
  6.    version 2 of the License, or (at your option) any later version.
  7.    
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU Library General Public
  14.    License along with this library; if not, write to the Free
  15.    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16.    MA 02111-1307, USA */
  17.  
  18. #ifndef _my_sys_h
  19. #define _my_sys_h
  20. #ifdef    __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24. #ifdef HAVE_AIOWAIT
  25. #include <sys/asynch.h>            /* Used by record-cache */
  26. typedef struct my_aio_result {
  27.   aio_result_t result;
  28.   int           pending;
  29. } my_aio_result;
  30. #endif
  31.  
  32. #ifndef THREAD
  33. extern int NEAR my_errno;        /* Last error in mysys */
  34. #else
  35. #include <my_pthread.h>
  36. #endif
  37.  
  38. #ifndef _m_ctype_h
  39. #include <m_ctype.h>                    /* for CHARSET_INFO */
  40. #endif
  41.  
  42. #include <stdarg.h>  
  43.  
  44. #define MYSYS_PROGRAM_USES_CURSES()  { error_handler_hook = my_message_curses;    mysys_uses_curses=1; }
  45. #define MYSYS_PROGRAM_DONT_USE_CURSES()  { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
  46. #define MY_INIT(name);        { my_progname= name; my_init(); }
  47.  
  48. #define MAXMAPS        (4)    /* Number of error message maps */
  49. #define ERRMOD        (1000)    /* Max number of errors in a map */
  50. #define ERRMSGSIZE    (SC_MAXWIDTH)    /* Max length of a error message */
  51. #define NRERRBUFFS    (2)    /* Buffers for parameters */
  52. #define MY_FILE_ERROR    ((uint) ~0)
  53.  
  54.     /* General bitmaps for my_func's */
  55. #define MY_FFNF        1    /* Fatal if file not found */
  56. #define MY_FNABP    2    /* Fatal if not all bytes read/writen */
  57. #define MY_NABP        4    /* Error if not all bytes read/writen */
  58. #define MY_FAE        8    /* Fatal if any error */
  59. #define MY_WME        16    /* Write message on error */
  60. #define MY_WAIT_IF_FULL 32    /* Wait and try again if disk full error */
  61. #define MY_RAID         64      /* Support for RAID (not the "Johnson&Johnson"-s one ;) */
  62. #define MY_DONT_CHECK_FILESIZE 128    /* Option to init_io_cache() */
  63. #define MY_LINK_WARNING 32    /* my_redel() gives warning if links */
  64. #define MY_COPYTIME    64    /* my_redel() copys time */
  65. #define MY_DELETE_OLD    256    /* my_create_with_symlink() */
  66. #define MY_RESOLVE_LINK 128    /* my_realpath(); Only resolve links */
  67. #define MY_HOLD_ORIGINAL_MODES 128  /* my_copy() holds to file modes */
  68. #define MY_REDEL_MAKE_BACKUP 256
  69. #define MY_SEEK_NOT_DONE 32    /* my_lock may have to do a seek */
  70. #define MY_DONT_WAIT    64    /* my_lock() don't wait if can't lock */
  71. #define MY_ZEROFILL    32    /* my_malloc(), fill array with zero */
  72. #define MY_ALLOW_ZERO_PTR 64    /* my_realloc() ; zero ptr -> malloc */
  73. #define MY_FREE_ON_ERROR 128    /* my_realloc() ; Free old ptr on error */
  74. #define MY_HOLD_ON_ERROR 256    /* my_realloc() ; Return old ptr on error */
  75. #define MY_THREADSAFE    128    /* pread/pwrite:  Don't allow interrupts */
  76.  
  77. #define MY_CHECK_ERROR    1    /* Params to my_end; Check open-close */
  78. #define MY_GIVE_INFO    2    /* Give time info about process*/
  79.  
  80. #define ME_HIGHBYTE    8    /* Shift for colours */
  81. #define ME_NOCUR    1    /* Don't use curses message */
  82. #define ME_OLDWIN    2    /* Use old window */
  83. #define ME_BELL        4    /* Ring bell then printing message */
  84. #define ME_HOLDTANG    8    /* Don't delete last keys */
  85. #define ME_WAITTOT    16    /* Wait for errtime secs of for a action */
  86. #define ME_WAITTANG    32    /* Wait for a user action  */
  87. #define ME_NOREFRESH    64    /* Dont refresh screen */
  88. #define ME_NOINPUT    128    /* Dont use the input libary */
  89. #define ME_COLOUR1    ((1 << ME_HIGHBYTE))    /* Possibly error-colours */
  90. #define ME_COLOUR2    ((2 << ME_HIGHBYTE))
  91. #define ME_COLOUR3    ((3 << ME_HIGHBYTE))
  92.  
  93.     /* My seek flags */
  94. #define MY_SEEK_SET    0
  95. #define MY_SEEK_CUR    1
  96. #define MY_SEEK_END    2
  97.  
  98.         /* My charsets_list flags */
  99. #define MY_NO_SETS       0
  100. #define MY_COMPILED_SETS 1      /* show compiled-in sets */
  101. #define MY_CONFIG_SETS   2      /* sets that have a *.conf file */
  102. #define MY_INDEX_SETS    4      /* all sets listed in the Index file */
  103. #define MY_LOADED_SETS    8      /* the sets that are currently loaded */
  104.  
  105.     /* Some constants */
  106. #define MY_WAIT_FOR_USER_TO_FIX_PANIC    60    /* in seconds */
  107. #define MY_WAIT_GIVE_USER_A_MESSAGE    10    /* Every 10 times of prev */
  108. #define MIN_COMPRESS_LENGTH        50    /* Don't compress small bl. */
  109. #define KEYCACHE_BLOCK_SIZE        1024
  110.  
  111.     /* root_alloc flags */
  112. #define MY_KEEP_PREALLOC    1
  113.  
  114.     /* defines when allocating data */
  115.  
  116. #ifdef SAFEMALLOC
  117. #define my_malloc(SZ,FLAG) _mymalloc( SZ, __FILE__, __LINE__, FLAG )
  118. #define my_malloc_ci(SZ,FLAG) _mymalloc( SZ, sFile, uLine, FLAG )
  119. #define my_realloc(PTR,SZ,FLAG) _myrealloc( PTR, SZ, __FILE__, __LINE__, FLAG )
  120. #define my_checkmalloc() _sanity( __FILE__, __LINE__ )
  121. #define my_free(PTR,FLAG) _myfree( PTR, __FILE__, __LINE__,FLAG)
  122. #define my_memdup(A,B,C) _my_memdup(A,B,__FILE__,__LINE__,C)
  123. #define my_strdup(A,C) _my_strdup(A,__FILE__,__LINE__,C)
  124. #define QUICK_SAFEMALLOC sf_malloc_quick=1
  125. #define NORMAL_SAFEMALLOC sf_malloc_quick=0
  126. extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
  127. extern ulonglong safemalloc_mem_limit;
  128. #define CALLER_INFO_PROTO   , const char *sFile, uint uLine
  129. #define CALLER_INFO         , __FILE__, __LINE__
  130. #define ORIG_CALLER_INFO    , sFile, uLine
  131. #else
  132. #define my_checkmalloc() (0)
  133. #undef TERMINATE
  134. #define TERMINATE(A) {}
  135. #define QUICK_SAFEMALLOC
  136. #define NORMAL_SAFEMALLOC
  137. extern gptr my_malloc(uint Size,myf MyFlags);
  138. #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG )
  139. extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags);
  140. extern void my_no_flags_free(gptr ptr);
  141. extern gptr my_memdup(const byte *from,uint length,myf MyFlags);
  142. extern my_string my_strdup(const char *from,myf MyFlags);
  143. #define my_free(PTR,FG) my_no_flags_free(PTR)
  144. #define CALLER_INFO_PROTO   /* nothing */
  145. #define CALLER_INFO         /* nothing */
  146. #define ORIG_CALLER_INFO    /* nothing */
  147. #endif
  148.  
  149. #ifdef HAVE_ALLOCA
  150. #if defined(_AIX) && !defined(__GNUC__)
  151. #pragma alloca
  152. #endif /* _AIX */
  153. #if defined(__GNUC__) && !defined(HAVE_ALLOCA_H)
  154. #define alloca __builtin_alloca
  155. #endif /* GNUC */
  156. #define my_alloca(SZ) alloca((size_t) (SZ))
  157. #define my_afree(PTR) {}
  158. #else
  159. #define my_alloca(SZ) my_malloc(SZ,MYF(0))
  160. #define my_afree(PTR) my_free(PTR,MYF(MY_WME))
  161. #endif /* HAVE_ALLOCA */
  162.  
  163. #ifdef MSDOS
  164. #ifdef __ZTC__
  165. void * __CDECL halloc(long count,size_t length);
  166. void   __CDECL hfree(void *ptr);
  167. #endif
  168. #if defined(USE_HALLOC)
  169. #if defined(_VCM_) || defined(M_IC80386)
  170. #undef USE_HALLOC
  171. #endif
  172. #endif
  173. #ifdef USE_HALLOC
  174. #define malloc(a) halloc((long) (a),1)
  175. #define free(a) hfree(a)
  176. #endif
  177. #endif /* MSDOS */
  178.  
  179. #ifdef HAVE_ERRNO_AS_DEFINE
  180. #include <errno.h>            /* errno is a define */
  181. #else
  182. extern int errno;            /* declare errno */
  183. #endif
  184. extern const char ** NEAR my_errmsg[];
  185. extern char NEAR errbuff[NRERRBUFFS][ERRMSGSIZE];
  186. extern char *home_dir;            /* Home directory for user */
  187. extern char *my_progname;        /* program-name (printed in errors) */
  188. extern char NEAR curr_dir[];        /* Current directory for user */
  189. extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
  190. extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
  191.                        myf MyFlags);
  192.  
  193. /* charsets */
  194. extern uint get_charset_number(const char *cs_name);
  195. extern const char *get_charset_name(uint cs_number);
  196. extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
  197. extern my_bool set_default_charset(uint cs, myf flags);
  198. extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
  199. extern my_bool set_default_charset_by_name(const char *cs_name, myf flags);
  200. extern void free_charsets(void);
  201. extern char *list_charsets(myf want_flags); /* my_free() this string... */
  202. extern char *get_charsets_dir(char *buf);
  203.  
  204.  
  205. /* statistics */
  206. extern ulong    _my_cache_w_requests,_my_cache_write,_my_cache_r_requests,
  207.         _my_cache_read;
  208. extern ulong     _my_blocks_used,_my_blocks_changed;
  209. extern ulong    my_file_opened,my_stream_opened, my_tmp_file_created;
  210. extern my_bool    key_cache_inited;
  211.  
  212.                     /* Point to current my_message() */
  213. extern void (*my_sigtstp_cleanup)(void),
  214.                     /* Executed before jump to shell */
  215.         (*my_sigtstp_restart)(void),
  216.         (*my_abort_hook)(int);
  217.                     /* Executed when comming from shell */
  218. extern int NEAR my_umask,        /* Default creation mask  */
  219.        NEAR my_umask_dir,
  220.        NEAR my_recived_signals,    /* Signals we have got */
  221.        NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
  222.        NEAR my_dont_interrupt;    /* call remember_intr when set */
  223. extern my_bool NEAR mysys_uses_curses, my_use_symdir;
  224. extern long lCurMemory,lMaxMemory;    /* from safemalloc */
  225.  
  226. extern ulong    my_default_record_cache_size;
  227. extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
  228.                NEAR my_disable_flush_key_blocks, NEAR my_disable_symlinks;
  229. extern char    wild_many,wild_one,wild_prefix;
  230. extern const char *charsets_dir;
  231. extern char *defaults_extra_file;
  232.  
  233. typedef struct wild_file_pack    /* Struct to hold info when selecting files */
  234. {
  235.   uint        wilds;        /* How many wildcards */
  236.   uint        not_pos;    /* Start of not-theese-files */
  237.   my_string    *wild;        /* Pointer to wildcards */
  238. } WF_PACK;
  239.  
  240. typedef struct st_typelib {    /* Different types saved here */
  241.   uint count;            /* How many types */
  242.   const char *name;            /* Name of typelib */
  243.   const char **type_names;
  244. } TYPELIB;
  245.  
  246. enum cache_type {READ_CACHE,WRITE_CACHE,READ_FIFO,READ_NET,WRITE_NET};
  247. enum flush_type { FLUSH_KEEP, FLUSH_RELEASE, FLUSH_IGNORE_CHANGED,
  248.           FLUSH_FORCE_WRITE};
  249.  
  250. typedef struct st_record_cache    /* Used when cacheing records */
  251. {
  252.   File file;
  253.   int    rc_seek,error,inited;
  254.   uint    rc_length,read_length,reclength;
  255.   my_off_t rc_record_pos,end_of_file;
  256.   byte    *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos;
  257. #ifdef HAVE_AIOWAIT
  258.   int    use_async_io;
  259.   my_aio_result aio_result;
  260. #endif
  261.   enum cache_type type;
  262. } RECORD_CACHE;
  263.  
  264. enum file_type { UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE,
  265.            STREAM_BY_FOPEN, STREAM_BY_FDOPEN, FILE_BY_MKSTEMP };
  266.  
  267. extern struct my_file_info
  268. {
  269.   my_string        name;
  270.   enum file_type    type;
  271. #if defined(THREAD) && !defined(HAVE_PREAD)  
  272.   pthread_mutex_t    mutex;
  273. #endif
  274. } my_file_info[MY_NFILE];
  275.  
  276.  
  277. typedef struct st_dynamic_array {
  278.   char *buffer;
  279.   uint elements,max_element;
  280.   uint alloc_increment;
  281.   uint size_of_element;
  282. } DYNAMIC_ARRAY;
  283.  
  284. typedef struct st_dynamic_string {
  285.   char *str;
  286.   uint length,max_length,alloc_increment;
  287. } DYNAMIC_STRING;
  288.  
  289.  
  290. typedef struct st_io_cache        /* Used when cacheing files */
  291. {
  292.   my_off_t pos_in_file,end_of_file;
  293.   byte    *rc_pos,*rc_end,*buffer,*rc_request_pos;
  294.   int (*read_function)(struct st_io_cache *,byte *,uint);
  295.   char *file_name;            /* if used with 'open_cached_file' */
  296.   char *dir,*prefix;
  297.   File file;
  298.   int    seek_not_done,error;
  299.   uint    buffer_length,read_length;
  300.   myf    myflags;            /* Flags used to my_read/my_write */
  301.   enum cache_type type;
  302. #ifdef HAVE_AIOWAIT
  303.   uint inited;
  304.   my_off_t aio_read_pos;
  305.   my_aio_result aio_result;
  306. #endif
  307. } IO_CACHE;
  308.  
  309. typedef int (*qsort2_cmp)(const void *, const void *, const void *);
  310.  
  311.     /* defines for mf_iocache */
  312.  
  313.     /* Test if buffer is inited */
  314. #define my_b_clear(info) (info)->buffer=0
  315. #define my_b_inited(info) (info)->buffer
  316. #define my_b_EOF INT_MIN
  317.  
  318. #define my_b_read(info,Buffer,Count) \
  319.   ((info)->rc_pos + (Count) <= (info)->rc_end ?\
  320.    (memcpy(Buffer,(info)->rc_pos,(size_t) (Count)), \
  321.     ((info)->rc_pos+=(Count)),0) :\
  322.    (*(info)->read_function)((info),Buffer,Count))
  323.  
  324. #define my_b_get(info) \
  325.   ((info)->rc_pos != (info)->rc_end ?\
  326.    ((info)->rc_pos++, (int) (uchar) (info)->rc_pos[-1]) :\
  327.    _my_b_get(info))
  328.  
  329. #define my_b_write(info,Buffer,Count) \
  330.   ((info)->rc_pos + (Count) <= (info)->rc_end ?\
  331.    (memcpy((info)->rc_pos,Buffer,(size_t) (Count)), \
  332.     ((info)->rc_pos+=(Count)),0) :\
  333.    _my_b_write(info,Buffer,Count))
  334.  
  335.     /* my_b_write_byte dosn't have any err-check */
  336. #define my_b_write_byte(info,chr) \
  337.   (((info)->rc_pos < (info)->rc_end) ?\
  338.    ((*(info)->rc_pos++)=(chr)) :\
  339.    (_my_b_write(info,0,0) , ((*(info)->rc_pos++)=(chr))))
  340.  
  341. #define my_b_fill_cache(info) \
  342.   (((info)->rc_end=(info)->rc_pos),(*(info)->read_function)(info,0,0))
  343.  
  344. #define my_b_tell(info) ((info)->pos_in_file + \
  345.              ((info)->rc_pos - (info)->rc_request_pos))
  346.  
  347. #define my_b_bytes_in_cache(info) ((uint) ((info)->rc_end - (info)->rc_pos))
  348.  
  349. typedef struct st_changeable_var {
  350.   const char *name;            /* Name of variable */
  351.   long *varptr;                /* Pointer to variable */
  352.   long def_value,            /* Default value */
  353.        min_value,            /* Min allowed value */
  354.        max_value,            /* Max allowed value */
  355.        sub_size,            /* Subtract this from given value */
  356.        block_size;            /* Value should be a mult. of this */
  357. } CHANGEABLE_VAR;
  358.  
  359.  
  360. /* structs for alloc_root */
  361.  
  362. #ifndef ST_USED_MEM_DEFINED
  363. #define ST_USED_MEM_DEFINED
  364. typedef struct st_used_mem {            /* struct for once_alloc */
  365.   struct st_used_mem *next;            /* Next block in use */
  366.   unsigned int left;                /* memory left in block  */
  367.   unsigned int size;                /* Size of block */
  368. } USED_MEM;
  369.  
  370. typedef struct st_mem_root {
  371.   USED_MEM *free;
  372.   USED_MEM *used;
  373.   USED_MEM *pre_alloc;
  374.   unsigned int    min_malloc;
  375.   unsigned int    block_size;
  376.  
  377.   void (*error_handler)(void);
  378. } MEM_ROOT;
  379. #endif
  380.  
  381.     /* Prototypes for mysys and my_func functions */
  382.  
  383. extern int my_copy(const char *from,const char *to,myf MyFlags);
  384. extern int my_append(const char *from,const char *to,myf MyFlags);
  385. extern int my_delete(const char *name,myf MyFlags);
  386. extern int my_getwd(my_string buf,uint size,myf MyFlags);
  387. extern int my_setwd(const char *dir,myf MyFlags);
  388. extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
  389. extern gptr my_once_alloc(uint Size,myf MyFlags);
  390. extern void my_once_free(void);
  391. extern my_string my_tempnam(const char *dir,const char *pfx,myf MyFlags);
  392. extern File my_open(const char *FileName,int Flags,myf MyFlags);
  393. extern File my_register_filename(File fd, const char *FileName,
  394.                  enum file_type type_of_file,
  395.                  uint error_message_number, myf MyFlags);
  396. extern File my_create(const char *FileName,int CreateFlags,
  397.               int AccsesFlags, myf MyFlags);
  398. extern int my_close(File Filedes,myf MyFlags);
  399. extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
  400. extern int my_readlink(char *to, const char *filename, myf MyFlags);
  401. extern int my_realpath(char *to, const char *filename, myf MyFlags);
  402. extern File my_create_with_symlink(const char *linkname, const char *filename,
  403.                    int createflags, int access_flags,
  404.                    myf MyFlags);
  405. extern int my_delete_with_symlink(const char *name, myf MyFlags);
  406. extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
  407. extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
  408. extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags);
  409. extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset,
  410.              myf MyFlags);
  411. extern int my_rename(const char *from,const char *to,myf MyFlags);
  412. extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
  413. extern my_off_t my_tell(File fd,myf MyFlags);
  414. extern uint my_write(File Filedes,const byte *Buffer,uint Count,
  415.              myf MyFlags);
  416. extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count,
  417.               my_off_t offset,myf MyFlags);
  418. extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags);
  419. extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count,
  420.               myf MyFlags);
  421. extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
  422. extern my_off_t my_ftell(FILE *stream,myf MyFlags);
  423. extern gptr _mymalloc(uint uSize,const char *sFile,
  424.               uint uLine, myf MyFlag);
  425. extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile,
  426.                uint uLine, myf MyFlag);
  427. extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...));
  428. extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag);
  429. extern int _sanity(const char *sFile,unsigned int uLine);
  430. extern gptr _my_memdup(const byte *from,uint length,
  431.                const char *sFile, uint uLine,myf MyFlag);
  432. extern my_string _my_strdup(const char *from, const char *sFile, uint uLine,
  433.                 myf MyFlag);
  434. #ifndef TERMINATE
  435. extern void TERMINATE(FILE *file);
  436. #endif
  437. extern void init_glob_errs(void);
  438. extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
  439. extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
  440. extern int my_fclose(FILE *fd,myf MyFlags);
  441. extern int my_chsize(File fd,my_off_t newlength,myf MyFlags);
  442. extern int my_error _VARARGS((int nr,myf MyFlags, ...));
  443. extern int my_printf_error _VARARGS((uint my_err, const char *format,
  444.                      myf MyFlags, ...)
  445.                     __attribute__ ((format (printf, 2, 4))));
  446. extern int my_vsnprintf( char *str, size_t n,
  447.                                 const char *format, va_list ap );
  448. extern int my_snprintf(char* to, size_t n, const char* fmt, ...);
  449. extern int my_message(uint my_err, const char *str,myf MyFlags);
  450. extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
  451. extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
  452. extern void my_init(void);
  453. extern void my_end(int infoflag);
  454. extern int my_redel(const char *from, const char *to, int MyFlags);
  455. extern int my_copystat(const char *from, const char *to, int MyFlags);
  456. extern my_string my_filename(File fd);
  457.  
  458. #ifndef THREAD
  459. extern void dont_break(void);
  460. extern void allow_break(void);
  461. #else
  462. #define dont_break()
  463. #define allow_break()
  464. #endif
  465.  
  466. extern void my_remember_signal(int signal_number,sig_handler (*func)(int));
  467. extern void caseup(my_string str,uint length);
  468. extern void casedn(my_string str,uint length);
  469. extern void caseup_str(my_string str);
  470. extern void casedn_str(my_string str);
  471. extern void case_sort(my_string str,uint length);
  472. extern uint dirname_part(my_string to,const char *name);
  473. extern uint dirname_length(const char *name);
  474. #define base_name(A) (A+dirname_length(A))
  475. extern int test_if_hard_path(const char *dir_name);
  476. extern char *convert_dirname(my_string name);
  477. extern void to_unix_path(my_string name);
  478. extern my_string fn_ext(const char *name);
  479. extern my_string fn_same(my_string toname,const char *name,int flag);
  480. extern my_string fn_format(my_string to,const char *name,const char *dsk,
  481.                const char *form,int flag);
  482. extern size_s strlength(const char *str);
  483. extern void pack_dirname(my_string to,const char *from);
  484. extern uint unpack_dirname(my_string to,const char *from);
  485. extern uint cleanup_dirname(my_string to,const char *from);
  486. extern uint system_filename(my_string to,const char *from);
  487. extern my_string unpack_filename(my_string to,const char *from);
  488. extern my_string intern_filename(my_string to,const char *from);
  489. extern my_string directory_file_name(my_string dst, const char *src);
  490. extern int pack_filename(my_string to, const char *name, size_s max_length);
  491. extern my_string my_path(my_string to,const char *progname,
  492.              const char *own_pathname_part);
  493. extern my_string my_load_path(my_string to, const char *path,
  494.                   const char *own_path_prefix);
  495. extern int wild_compare(const char *str,const char *wildstr);
  496. extern my_string my_strcasestr(const char *src,const char *suffix);
  497. extern int my_strcasecmp(const char *s,const char *t);
  498. extern int my_strsortcmp(const char *s,const char *t);
  499. extern int my_casecmp(const char *s,const char *t,uint length);
  500. extern int my_sortcmp(const char *s,const char *t,uint length);
  501. extern int my_sortncmp(const char *s,uint s_len, const char *t,uint t_len);
  502. extern WF_PACK *wf_comp(my_string str);
  503. extern int wf_test(struct wild_file_pack *wf_pack,const char *name);
  504. extern void wf_end(struct wild_file_pack *buffer);
  505. extern size_s strip_sp(my_string str);
  506. extern void get_date(my_string to,int timeflag,time_t use_time);
  507. extern void soundex(my_string out_pntr, my_string in_pntr,pbool remove_garbage);
  508. extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file,
  509.                  uint reclength,enum cache_type type,
  510.                  pbool use_async_io);
  511. extern int read_cache_record(RECORD_CACHE *info,byte *to);
  512. extern int end_record_cache(RECORD_CACHE *info);
  513. extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos,
  514.                   const byte *record,uint length);
  515. extern int flush_write_cache(RECORD_CACHE *info);
  516. extern long my_clock(void);
  517. extern sig_handler sigtstp_handler(int signal_number);
  518. extern void handle_recived_signals(void);
  519. extern int init_key_cache(ulong use_mem,ulong leave_this_much_mem);
  520. extern byte *key_cache_read(File file,my_off_t filepos,byte* buff,uint length,
  521.                 uint block_length,int return_buffer);
  522. extern int key_cache_write(File file,my_off_t filepos,byte* buff,uint length,
  523.                uint block_length,int force_write);
  524. extern int flush_key_blocks(int file, enum flush_type type);
  525. extern void end_key_cache(void);
  526. extern sig_handler my_set_alarm_variable(int signo);
  527. extern void my_string_ptr_sort(void *base,uint items,size_s size);
  528. extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
  529.                   size_s size_of_element,uchar *buffer[]);
  530. extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size,
  531.               qsort2_cmp cmp, void *cmp_argument);
  532. extern qsort2_cmp get_ptr_compare(uint);
  533. extern int init_io_cache(IO_CACHE *info,File file,uint cachesize,
  534.              enum cache_type type,my_off_t seek_offset,
  535.              pbool use_async_io, myf cache_myflags);
  536. extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
  537.                    my_off_t seek_offset,pbool use_async_io,
  538.                    pbool clear_cache);
  539. extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count);
  540. extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count);
  541. extern int _my_b_get(IO_CACHE *info);
  542. extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count);
  543. extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count);
  544. extern int my_block_write(IO_CACHE *info, const byte *Buffer,
  545.               uint Count, my_off_t pos);
  546. extern int flush_io_cache(IO_CACHE *info);
  547. extern int end_io_cache(IO_CACHE *info);
  548. extern uint my_b_fill(IO_CACHE *info);
  549. extern void my_b_seek(IO_CACHE *info,my_off_t pos);
  550. extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length);
  551. extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...);
  552. extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
  553. extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
  554.                  const char *prefix, uint cache_size,
  555.                  myf cache_myflags);
  556. extern my_bool real_open_cached_file(IO_CACHE *cache);
  557. extern void close_cached_file(IO_CACHE *cache);
  558. File create_temp_file(char *to, const char *dir, const char *pfx,
  559.               int mode, myf MyFlags);
  560. #define my_init_dynamic_array(A,B,C,D) init_dynamic_array(A,B,C,D CALLER_INFO)
  561. #define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array(A,B,C,D ORIG_CALLER_INFO)
  562. extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size,
  563.       uint init_alloc,uint alloc_increment CALLER_INFO_PROTO);
  564. extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element);
  565. extern byte *alloc_dynamic(DYNAMIC_ARRAY *array);
  566. extern byte *pop_dynamic(DYNAMIC_ARRAY*);
  567. extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
  568. extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index);
  569. extern void delete_dynamic(DYNAMIC_ARRAY *array);
  570. extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index);
  571. extern void freeze_size(DYNAMIC_ARRAY *array);
  572. #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
  573. #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
  574. #define push_dynamic(A,B) insert_dynamic(A,B)
  575.  
  576. extern int find_type(my_string x,TYPELIB *typelib,uint full_name);
  577. extern void make_type(my_string to,uint nr,TYPELIB *typelib);
  578. extern const char *get_type(TYPELIB *typelib,uint nr);
  579. extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
  580.                    uint init_alloc,uint alloc_increment);
  581. extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
  582. my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
  583.               uint length);
  584. extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
  585. extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size);
  586. extern void dynstr_free(DYNAMIC_STRING *str);
  587. void set_all_changeable_vars(CHANGEABLE_VAR *vars);
  588. my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars);
  589. my_bool set_changeable_varval(const char *var, ulong val,
  590.                   CHANGEABLE_VAR *vars);
  591. #ifdef HAVE_MLOCK
  592. extern byte *my_malloc_lock(uint length,myf flags);
  593. extern void my_free_lock(byte *ptr,myf flags);
  594. #else
  595. #define my_malloc_lock(A,B) my_malloc((A),(B))
  596. #define my_free_lock(A,B) my_free((A),(B))
  597. #endif
  598. #define alloc_root_inited(A) ((A)->min_malloc != 0)
  599. void init_alloc_root(MEM_ROOT *mem_root, uint block_size, uint pre_alloc_size);
  600. gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size);
  601. void free_root(MEM_ROOT *root, myf MyFLAGS);
  602. char *strdup_root(MEM_ROOT *root,const char *str);
  603. char *memdup_root(MEM_ROOT *root,const char *str,uint len);
  604. void load_defaults(const char *conf_file, const char **groups,
  605.            int *argc, char ***argv);
  606. void free_defaults(char **argv);
  607. void print_defaults(const char *conf_file, const char **groups);
  608. my_bool my_compress(byte *, ulong *, ulong *);
  609. my_bool my_uncompress(byte *, ulong *, ulong *);
  610. byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen);
  611. ulong checksum(const byte *mem, uint count);
  612.  
  613. #if defined(_MSC_VER) && !defined(__WIN__)
  614. extern void sleep(int sec);
  615. #endif
  616. #ifdef __WIN__
  617. extern my_bool have_tcpip;        /* Is set if tcpip is used */
  618. #endif
  619.  
  620. #ifdef    __cplusplus
  621. }
  622. #endif
  623. #include "raid.h"
  624. #endif /* _my_sys_h */
  625.